/**
 * 
 */
package org.jinion.database.model.impl;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.jinion.database.DataType;
import org.jinion.database.model.AbstractTable;

/**
 * This class is the model of the returned columns by query operation.
 * @author zhlmmc
 *
 */
public class TableColumn {
	private static final Log log = LogFactory.getLog(TableColumn.class);
	
	/**
	 * index starts from 1, 2...
	 */
	private int index;
	private String columnLable;
	private String columnName;
	private DataType dataType;
	private String tableName;
	private boolean autoIncrement;
	private boolean nullable;
	private AbstractTable parentTable;
	
	public TableColumn(AbstractTable parentTable){
		this.parentTable = parentTable;
		
		log.debug("New TableColumn created.");
	}
	
	/**
	 * Index starts from 1, 2...
	 * @param parentTable
	 * @param index the index of the column in parentTable
	 */
	public TableColumn(AbstractTable parentTable, int index){
		this(parentTable);
		this.index = index;
		
		log.debug("New TableColumn created, columnIndex: " + index);
	}
	
	public int getIndex() {
		return index;
	}
	public String getColumnLable() {
		return columnLable;
	}
	public void setColumnLable(String columnLable) {
		this.columnLable = columnLable;
	}
	public String getColumnName() {
		return columnName;
	}
	public void setColumnName(String columnName) {
		this.columnName = columnName;
	}
	public String getTableName() {
		return tableName;
	}
	public void setTableName(String tableName) {
		this.tableName = tableName;
	}
	public boolean isAutoIncrement() {
		return autoIncrement;
	}
	public void setAutoIncrement(boolean autoIncrement) {
		this.autoIncrement = autoIncrement;
	}
	public boolean isNullable() {
		return nullable;
	}
	public void setNullable(boolean nullable) {
		this.nullable = nullable;
	}
	public DataType getDataType() {
		return dataType;
	}
	public void setDataType(DataType dataType) {
		this.dataType = dataType;
	}

	public AbstractTable getParentTable() {
		return parentTable;
	}
	
}
